package com.jf.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-09-03
 * Time:17:47
 */
@WebFilter(urlPatterns = "/chain/*")
public class ChainFilter2 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("ChainFilter2 init");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("ChainFilter2 thread name: " + Thread.currentThread().getName());
        System.out.println("ChainFilter2 thread id: " + Thread.currentThread().getId());
        System.out.println("ChainFilter2 doFilter");
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println("ChainFilter2 doFilter");
    }

    @Override
    public void destroy() {
        System.out.println("ChainFilter2 destroy");
    }
}
